﻿

CREATE FUNCTION QIC.DelegateNameFactory_DEFAULT(@InterfaceName VARCHAR(50), @ObjectName VARCHAR(255))
RETURNS VARCHAR(50)
AS
BEGIN

	DECLARE @Name VARCHAR(255)

	IF @InterfaceName = @ObjectName RETURN NULL
	IF LEFT(@ObjectName, LEN(@InterfaceName)) <> @InterfaceName RETURN NULL

	SET @Name = RIGHT(@ObjectName,LEN(@ObjectName) - LEN(@InterfaceName))

	IF CHARINDEX('_',@Name,1) = 0 RETURN @Name

	RETURN LEFT(@Name,CHARINDEX('_',@Name,1)-1)
END